﻿using NetFrame.EnDecode;
using ProtoBuf;

namespace NetFrame {
    [ProtoContract]
    public class TransModel {
        [ProtoMember(1)]
        public byte type;
        [ProtoMember(2)]
        public int area;
        [ProtoMember(3)]
        public int command;
        [ProtoMember(4)]
        public byte[] message;

        public TransModel() { }
        public TransModel(byte t, int a, int c, byte[] m = null) {
            type = t;
            area = a;
            command = c;
            message = m;
        }

        public T getMessage<T>() {
            if (message == null) {
                return default(T);
            }

            return SeProbuf.De<T>(message);
        }
    }
}
